from sympy.geometry.polygon import Polygon
from sympy import S

from .prism import Prism
from .polygon3D import Polygon3D


def _pre_do(side, args):
    if isinstance(side, (Polygon, Polygon3D)) and args[0] in S.Reals:
        return (side, args[0])
    if hasattr(side, "__iter__"):
        a, b, c = list(side)
        return (Polygon((0, 0), (a, 0), (a, b), (0, b)), c)
    return (Polygon((0, 0), (side, 0), (side, side), (0, side)), side)


class Cube(Prism):
    def __new__(cls, side, *args, **kwargs) -> None:
        bottom, high = _pre_do(side, args)
        return super().__new__(cls, bottom, high, *args, **kwargs)
    